#include <stdio.h>
#include <stdlib.h>

#include "lib.h"
#include "cardmgr.h"
#include "shue.h"
#include "r250.h"

//
// tests save/restore shue()
//
// run the test twice (using the same seed):
//		1)	deckregen {seed} >out
//		2)	deckregen {seed} 1 >out2
// diff out out2
//

static R250 r250;

uint32
getrand()
{
	return (uint32)r250.rani();
}

void
main(int32 argc, char* argv[])
{
	CardMgr mgr;
	Shue shue(&mgr, 8);
	int32 i, j;
	uint32 seed;
	ShueSave ss;

	if (argc <= 1)
		seed = getrand();
	else
		seed = (uint32)atoi(argv[1]);
	
	shue.shuffle(seed);

	if (argc > 2)
	{
		shue.save(&ss);

		for (i = 0; i < 100; i++)
			shue.getCard();

		shue.restore(&ss);
	}

	printf("Seed = %08x\n", seed);
	for (i = 0; i < mgr.getDeckSize(); i++)
	{
		for (j = 0; j < 8; j++)
			printf("%02x ", shue.getCard());
		printf("\n");
	}
}
